package homework.exp06;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;

public class F {
    static Scanner cin = null;

    static {
        try {
            cin = new Scanner(new FileInputStream(new File("src/homework/exp06/F.in")));
        } catch (IOException e) {
            cin = new Scanner(System.in);
        }
    }
    static int a[][] = new int[101][101];
    static int book[] = new int[101];
    static int n,sum;
    public static void main(String[] args) {
        n = cin.nextInt();
        for(int i=0;i<n;i++) {
            for(int j=0;j<n;j++) {
                a[i][j]=cin.nextInt();
            }
        }
        book[0]=1;
        dfs(0,a);
        System.out.println();
    }
    public static void dfs(int x,int[][]a) {
        System.out.print(x+" ");
        sum++;
        if(sum==n)
            return;
        for(int i=0;i<n;i++) {
            if(a[x][i]==1&&book[i]==0)
            {
                book[i]=1;
                dfs(i,a);
            }
        }
    }
}